﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Circle.Domain.Entity;
using Circle.Domain.Interface.UnitOfWork;
using Circle.Domain.Interface.Service;
using System.Web.Mvc;
using Circle.Manager;

namespace Circle.Web
{
    public static class WebCircleConfig
    {
        private static Setting _defaultSetting;
        private static Dictionary<string, string> _localeResources;

        public static void Load()
        {
            LoadDefaultSetting();
            _localeResources = MessageManager.Resources;
        }

        private static void LoadDefaultSetting()
        {
            using (IUnitOfWorkManager manager = DependencyResolver.Current.GetService<IUnitOfWorkManager>())
            {
                ISettingService settingService = DependencyResolver.Current.GetService<ISettingService>();
                _defaultSetting = settingService.GetDefaultSetting();
                if (_defaultSetting == null)
                {
                    throw new Exception("Default setting is required!");
                }
            }
        }


        public static Setting DefaultSetting
        {
            get { return _defaultSetting; }
        }

        public static Dictionary<string, string> LocaleResources
        {
            get { return _localeResources; }
        }
    }
}